/*
 * @Description: 点云订阅
 * @Author: Sang Hao
 * @Date: 2021-09-15 17:10:53
 * @LastEditTime: 2021-11-06 20:44:30
 * @LastEditors: Sang Hao
 */

#ifndef LIDAR_SLAM_CLOUD_PUBLISHER_HPP_
#define LIDAR_SLAM_CLOUD_PUBLISHER_HPP_

#include <ros/ros.h>
#include <sensor_msgs/PointCloud2.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl_conversions/pcl_conversions.h>

#include "lidar_slam/sensor_data/cloud_data.hpp"
#include "lidar_slam/sensor_data/cloud_rgb_data.hpp"

namespace lidar_slam {
class CloudPublisher {
private:
	ros::NodeHandle nh_;
	ros::Publisher	publisher_;
	std::string 	frame_id_;

private:
	void PublishData(CloudData::CLOUD_PTR& cloud_ptr_input, ros::Time time);
	void PublishData(CloudRGBData::CLOUD_PTR& cloud_ptr_input, ros::Time time);

public:
	CloudPublisher(	ros::NodeHandle& nh, 
					std::string 	 topic_name,
					std::string 	 frame_id, 
					size_t			 buff_size);
	CloudPublisher() = default;
	void Publish(CloudData::CLOUD_PTR& cloud_ptr_input, double time);
	void Publish(CloudRGBData::CLOUD_PTR& cloud_ptr_input, double time);
	void Publish(CloudData::CLOUD_PTR& cloud_ptr_input);
	void Publish(CloudRGBData::CLOUD_PTR& cloud_ptr_input);
	bool HasSubscribers();
};
}

#endif